1 //Global variables
2
3 var
winCal;
4 var
dtToday;
5 var
Cal;
6 var
MonthName;
7 var
WeekDayName1;
8 var
WeekDayName2;
9 var
exDateTime;//Existing Date and Time
10 var
selDate;//selected date. version 1.7
11 var
calSpanID = "calBorder"; // span ID
12 var
domStyle = null; // span DOM object with style
13 var
cnLeft = "0";//left coordinate of calendar span
14 var
cnTop = "0";//top coordinate of calendar span
15 var
xpos = 0; // mouse x position
16 var
ypos = 0; // mouse y position
17 var
calHeight = 0; // calendar height
18 var
CalWidth = 208;// calendar width
19 var
CellWidth = 30;// width of day cell.
20 var
TimeMode = 24;// TimeMode value. 12 or 24
21 var
StartYear = 1940; //First Year in drop down year selection
22 var
EndYear = 5; // The last year of pickable date. if current year is 2011, the last year that still picker will be 2016 (2011+5)
23 var
CalPosOffsetX = -1; //X position offset relative to calendar icon, can be negative value
24 var
CalPosOffsetY = 0; //Y position offset relative to calendar icon, can be negative value
25
26 //Configurable parameters start

27 var
SpanBorderColor = "#000000";//span border color
28 var
SpanBgColor = "#FFFFFF"; //span background color
29 var
MonthYearColor = "#cc0033"; //Font Color of Month and Year in Calendar header.
30 var
WeekHeadColor = "#18861B"; //var WeekHeadColor="#18861B";//Background Color in Week header.
31 var
SundayColor = "#C0F64F"; //var SundayColor="#C0F64F";//Background color of Sunday.
32 var
SaturdayColor = "#C0F64F"; //Background color of Saturday.
33 var
WeekDayColor = "#FFEDA6"; //Background color of weekdays.
34 var
FontColor = "blue"; //color of font in Calendar day cell.
35 var
TodayColor = "#ffbd35"; //var TodayColor="#FFFF33";//Background color of today.
36 var
SelDateColor = "#8DD53C"; //var SelDateColor = "#8DD53C";//Backgrond color of selected date in textbox.
37 var
YrSelColor = "#cc0033"; //color of font of Year selector.
38 var
MthSelColor = "#cc0033"; //color of font of Month selector if "MonthSelector" is "arrow".
39 var
HoverColor = "#E0FF38"; //color when mouse move over.
40 var
DisableColor = "#999966"; //color of disabled cell.
41 var
CalBgColor = "#ffffff"; //Background color of Calendar window.
42
43 var
WeekChar = 2;//number of character for week day. if 2 then Mo,Tu,We. if 3 then Mon,Tue,Wed.
44 var
DateSeparator = "-";//Date Separator, you can change it to "-" if you want.
45 var
ShowLongMonth = true;//Show long month name in Calendar header. example: "January".
46 var
ShowMonthYear = true;//Show Month and Year in Calendar header.
47 var
ThemeBg = "";//Background image of Calendar window.
48 var
PrecedeZero = true;//Preceding zero [true|false]
49 var
MondayFirstDay = true;//true:Use Monday as first day; false:Sunday as first day. [true|false] //added in version 1.7
50 var
UseImageFiles = true;//Use image files with "arrows" and "close" button
51 var
imageFilesPath = "images2/";
52 //Configurable parameters end
53
54 //use the Month and Weekday
in your preferred language.
55 var
MonthName = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
56 var
WeekDayName1 = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"];
57 var
WeekDayName2 = ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"];
58
59
60 //end Configurable parameters
61
62 //end Global variable
63
64
65 // Calendar prototype

66 function Calendar(pDate, pCtrl)
67 {
68     
//Properties
69     
this.Date = pDate.getDate();//selected date
70     
this.Month = pDate.getMonth();//selected month number
71     
this.Year = pDate.getFullYear();//selected year in 4 digits
72     
this.Hours = pDate.getHours();
73
74     
if (pDate.getMinutes() < 10)
75     {
76         
this.Minutes = "0" + pDate.getMinutes();
77     }
78     
else
79     {
80         
this.Minutes = pDate.getMinutes();
81     }
82
83     
if (pDate.getSeconds() < 10)
84     {
85         
this.Seconds = "0" + pDate.getSeconds();
86     }
87     
else
88     {
89         
this.Seconds = pDate.getSeconds();
90     }
91     
this.MyWindow = winCal;
92     
this.Ctrl = pCtrl;
93     
this.Format = "ddMMyyyy";
94     
this.Separator = DateSeparator;
95     
this.ShowTime = false;
96     
this.Scroller = "DROPDOWN";
97     
if (pDate.getHours() < 12)
98     {
99         
this.AMorPM = "AM";
100     }
101     
else
102     {
103         
this.AMorPM = "PM";
104     }
105     
this.ShowSeconds = false;
106     
this.EnableDateMode = ""
107 }
108
109 Calendar.prototype.GetMonthIndex = function (shortMonthName)
110 {
111     
for (var i = 0; i < 12; i += 1)
112     {
113         
if (MonthName[i].substring(0, 3).toUpperCase() === shortMonthName.toUpperCase())
114         {
115             
return i;
116         }
117     }
118 };
119
120 Calendar.prototype.IncYear = function () {
121     
if (Cal.Year <= dtToday.getFullYear()+EndYear)
122         Cal.Year +=
1;
123 };
124
125 Calendar.prototype.DecYear = function () {
126     
if (Cal.Year > StartYear)
127         Cal.Year -=
1;
128 };
129
130 Calendar.prototype.IncMonth = function() {
131     
if (Cal.Year <= dtToday.getFullYear() + EndYear) {
132         Cal.Month +=
1;
133         
if (Cal.Month >= 12) {
134             Cal.Month =
0;
135             Cal.IncYear();
136         }
137     }
138 };
139
140 Calendar.prototype.DecMonth = function() {
141     
if (Cal.Year >= StartYear) {
142         Cal.Month -=
1;
143         
if (Cal.Month < 0) {
144             Cal.Month =
11;
145             Cal.DecYear();
146         }
147     }
148 };
149
150 Calendar.prototype.SwitchMth = function (intMth)
151 {
152     Cal.Month = parseInt(intMth,
10);
153 };
154
155 Calendar.prototype.SwitchYear = function (intYear)
156 {
157     Cal.Year = parseInt(intYear,
10);
158 };
159
160 Calendar.prototype.SetHour = function(intHour) {
161     
var MaxHour,
162     MinHour,
163     HourExp =
new RegExp("^\\d\\d"),
164     SingleDigit =
new RegExp("^\\d{1}$");
165
166     
if (TimeMode === 24) {
167         MaxHour =
23;
168         MinHour =
0;
169     }
170     
else if (TimeMode === 12) {
171         MaxHour =
12;
172         MinHour =
1;
173     }
174     
else {
175         alert(
"TimeMode can only be 12 or 24");
176     }
177
178     
if ((HourExp.test(intHour) || SingleDigit.test(intHour)) && (parseInt(intHour, 10) > MaxHour)) {
179         intHour = MinHour;
180     }
181
182     
else if ((HourExp.test(intHour) || SingleDigit.test(intHour)) && (parseInt(intHour, 10) < MinHour)) {
183         intHour = MaxHour;
184     }
185
186     intHour = parseInt(intHour,
10);
187     
if (SingleDigit.test(intHour)) {
188         intHour =
"0" + intHour;
189     }
190
191     
if (HourExp.test(intHour) && (parseInt(intHour, 10) <= MaxHour) && (parseInt(intHour, 10) >= MinHour)) {
192         
if ((TimeMode === 12) && (Cal.AMorPM === "PM")) {
193             
if (parseInt(intHour, 10) === 12) {
194                 Cal.Hours =
12;
195             }
196             
else {
197                 Cal.Hours = parseInt(intHour,
10) + 12;
198             }
199         }
200
201         
else if ((TimeMode === 12) && (Cal.AMorPM === "AM")) {
202             
if (intHour === 12) {
203                 intHour -=
12;
204             }
205
206             Cal.Hours = parseInt(intHour,
10);
207         }
208
209         
else if (TimeMode === 24) {
210             Cal.Hours = parseInt(intHour,
10);
211         }
212     }
213
214 };
215
216 Calendar.prototype.SetMinute = function (intMin)
217 {
218     
var MaxMin = 59,
219     MinMin =
0,
220
221     SingleDigit =
new RegExp("\\d"),
222     SingleDigit2 =
new RegExp("^\\d{1}$"),
223     MinExp =
new RegExp("^\\d{2}$"),
224
225     strMin =
0;
226
227     
if ((MinExp.test(intMin) || SingleDigit.test(intMin)) && (parseInt(intMin, 10) > MaxMin))
228     {
229         intMin = MinMin;
230     }
231
232     
else if ((MinExp.test(intMin) || SingleDigit.test(intMin)) && (parseInt(intMin, 10) < MinMin))
233     {
234         intMin = MaxMin;
235     }
236
237     strMin = intMin +
"";
238     
if (SingleDigit2.test(intMin))
239     {
240         strMin =
"0" + strMin;
241     }
242
243     
if ((MinExp.test(intMin) || SingleDigit.test(intMin)) && (parseInt(intMin, 10) <= 59) && (parseInt(intMin, 10) >= 0))
244     {
245         Cal.Minutes = strMin;
246     }
247 };
248
249 Calendar.prototype.SetSecond = function (intSec)
250 {
251     
var MaxSec = 59,
252     MinSec =
0,
253
254     SingleDigit =
new RegExp("\\d"),
255     SingleDigit2 =
new RegExp("^\\d{1}$"),
256     SecExp =
new RegExp("^\\d{2}$"),
257
258     strSec =
0;
259
260     
if ((SecExp.test(intSec) || SingleDigit.test(intSec)) && (parseInt(intSec, 10) > MaxSec))
261     {
262         intSec = MinSec;
263     }
264
265     
else if ((SecExp.test(intSec) || SingleDigit.test(intSec)) && (parseInt(intSec, 10) < MinSec))
266     {
267         intSec = MaxSec;
268     }
269
270     strSec = intSec +
"";
271     
if (SingleDigit2.test(intSec))
272     {
273         strSec =
"0" + strSec;
274     }
275
276     
if ((SecExp.test(intSec) || SingleDigit.test(intSec)) && (parseInt(intSec, 10) <= 59) && (parseInt(intSec, 10) >= 0))
277     {
278         Cal.Seconds = strSec;
279     }
280
281 };
282
283 Calendar.prototype.SetAmPm = function (pvalue)
284 {
285     
this.AMorPM = pvalue;
286     
if (pvalue === "PM")
287     {
288         
this.Hours = parseInt(this.Hours, 10) + 12;
289         
if (this.Hours === 24)
290         {
291             
this.Hours = 12;
292         }
293     }
294
295     
else if (pvalue === "AM")
296     {
297         
this.Hours -= 12;
298     }
299 };
300
301 Calendar.prototype.getShowHour = function() {
302     
var finalHour;
303
304     
if (TimeMode === 12) {
305         
if (parseInt(this.Hours, 10) === 0) {
306             
this.AMorPM = "AM";
307             finalHour = parseInt(
this.Hours, 10) + 12;
308         }
309
310         
else if (parseInt(this.Hours, 10) === 12) {
311             
this.AMorPM = "PM";
312             finalHour =
12;
313         }
314
315         
else if (this.Hours > 12) {
316             
this.AMorPM = "PM";
317             
if ((this.Hours - 12) < 10) {
318                 finalHour =
"0" + ((parseInt(this.Hours, 10)) - 12);
319             }
320             
else {
321                 finalHour = parseInt(
this.Hours, 10) - 12;
322             }
323         }
324         
else {
325             
this.AMorPM = "AM";
326             
if (this.Hours < 10) {
327                 finalHour =
"0" + parseInt(this.Hours, 10);
328             }
329             
else {
330                 finalHour =
this.Hours;
331             }
332         }
333     }
334
335     
else if (TimeMode === 24) {
336         
if (this.Hours < 10) {
337             finalHour =
"0" + parseInt(this.Hours, 10);
338         }
339         
else {
340             finalHour =
this.Hours;
341         }
342     }
343
344     
return finalHour;
345 };
346
347 Calendar.prototype.getShowAMorPM = function ()
348 {
349     
return this.AMorPM;
350 };
351
352 Calendar.prototype.GetMonthName = function (IsLong)
353 {
354     
var Month = MonthName[this.Month];
355     
if (IsLong)
356     {
357         
return Month;
358     }
359     
else
360     {
361         
return Month.substr(0, 3);
362     }
363 };
364
365 Calendar.prototype.GetMonDays = function() {
//Get number of days in a month
366
367     
var DaysInMonth = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
368     
if (Cal.IsLeapYear()) {
369         DaysInMonth[
1] = 29;
370     }
371
372     
return DaysInMonth[this.Month];
373 };
374
375 Calendar.prototype.IsLeapYear = function ()
376 {
377     
if ((this.Year % 4) === 0)
378     {
379         
if ((this.Year % 100 === 0) && (this.Year % 400) !== 0)
380         {
381             
return false;
382         }
383         
else
384         {
385             
return true;
386         }
387     }
388     
else
389     {
390         
return false;
391     }
392 };
393
394 Calendar.prototype.FormatDate = function (pDate)
395 {
396     
var MonthDigit = this.Month + 1;
397     
if (PrecedeZero === true)
398     {
399         
if ((pDate < 10) && String(pDate).length===1) //length checking added in version 2.2
400         {
401             pDate =
"0" + pDate;
402         }
403         
if (MonthDigit < 10)
404         {
405             MonthDigit =
"0" + MonthDigit;
406         }
407     }
408
409     
switch (this.Format.toUpperCase())
410     {
411         
case "DDMMYYYY":
412         
return (pDate + DateSeparator + MonthDigit + DateSeparator + this.Year);
413         
case "DDMMMYYYY":
414         
return (pDate + DateSeparator + this.GetMonthName(false) + DateSeparator + this.Year);
415         
case "MMDDYYYY":
416         
return (MonthDigit + DateSeparator + pDate + DateSeparator + this.Year);
417         
case "MMMDDYYYY":
418         
return (this.GetMonthName(false) + DateSeparator + pDate + DateSeparator + this.Year);
419         
case "YYYYMMDD":
420         
return (this.Year + DateSeparator + MonthDigit + DateSeparator + pDate);
421         
case "YYMMDD":
422         
return (String(this.Year).substring(2, 4) + DateSeparator + MonthDigit + DateSeparator + pDate);
423         
case "YYMMMDD":
424         
return (String(this.Year).substring(2, 4) + DateSeparator + this.GetMonthName(false) + DateSeparator + pDate);
425         
case "YYYYMMMDD":
426         
return (this.Year + DateSeparator + this.GetMonthName(false) + DateSeparator + pDate);
427         
default:
428         
return (pDate + DateSeparator + (this.Month + 1) + DateSeparator + this.Year);
429     }
430 };

431
432 // end Calendar prototype

433
434 function GenCell(pValue, pHighLight, pColor, pClickable)
435 {
//Generate table cell with value
436     
var PValue,
437     PCellStr,
438     PClickable,
439     vTimeStr;
440
441     
if (!pValue)
442     {
443         PValue =
"";
444     }
445     
else
446     {
447         PValue = pValue;
448     }
449
450     
if (pColor === undefined)
451         pColor = CalBgColor;
452     
453     
if (pClickable !== undefined){
454         PClickable = pClickable;
455     }
456     
else{
457         PClickable =
true;
458     }
459
460     
if (Cal.ShowTime)
461     {
462         vTimeStr =
' ' + Cal.Hours + ':' + Cal.Minutes;
463         
if (Cal.ShowSeconds)
464         {
465             vTimeStr +=
':' + Cal.Seconds;
466         }
467         
if (TimeMode === 12)
468         {
469             vTimeStr +=
' ' + Cal.AMorPM;
470         }
471     }
472
473     
else
474     {
475         vTimeStr =
"";
476     }
477
478     
if (PValue !== "")
479     {
480         
if (PClickable === true) {
481             
if (Cal.ShowTime === true)
482             { PCellStr =
"<td id='c" + PValue + "' class='calTD' style='text-align:center;cursor:pointer;background-color:"+pColor+"' onmousedown='selectDate(this," + PValue + ");'>" + PValue + "</td>"; }
483             
else { PCellStr = "<td class='calTD' style='text-align:center;cursor:pointer;background-color:" + pColor + "' onmouseover='changeBorder(this, 0);' onmouseout=\"changeBorder(this, 1, '" + pColor + "');\" onClick=\"javascript:callback('" + Cal.Ctrl + "','" + Cal.FormatDate(PValue) + "');\">" + PValue + "</td>"; }
484         }
485         
else
486         { PCellStr =
"<td style='text-align:center;background-color:"+pColor+"' class='calTD'>"+PValue+"</td>"; }
487     }
488     
else
489     { PCellStr =
"<td style='text-align:center;background-color:"+pColor+"' class='calTD'>&nbsp;</td>"; }
490
491     
return PCellStr;
492 }
493
494 function RenderCssCal(bNewCal)
495 {
496     
if (typeof bNewCal === "undefined" || bNewCal !== true)
497     {
498         bNewCal =
false;
499     }
500     
var vCalHeader,
501     vCalData,
502     vCalTime =
"",
503     vCalClosing =
"",
504     winCalData =
"",
505     CalDate,
506
507     i,
508     j,
509
510     SelectStr,
511     vDayCount =
0,
512     vFirstDay,
513
514     WeekDayName = [],
//Added version 1.7
515     strCell,
516
517     showHour,
518     ShowArrows =
false,
519     HourCellWidth =
"35px", //cell width with seconds.
520
521     SelectAm,
522     SelectPm,
523
524     funcCalback,
525
526     headID,
527     e,
528     cssStr,
529     style,
530     cssText,
531     span;
532
533     calHeight =
0; // reset the window height on refresh
534
535     
// Set the default cursor for the calendar
536
537     winCalData =
"<span style='cursor:auto;'>";
538     vCalHeader =
"<table style='background-color:"+CalBgColor+";width:200px;padding:0;margin:5px auto 5px auto'><tbody>";
539
540     
//Table for Month & Year Selector
541
542     vCalHeader +=
"<tr><td colspan='7'><table border='0' width='200px' cellpadding='0' cellspacing='0'><tr>";
543     
//******************Month and Year selector in dropdown list************************
544
545     
if (Cal.Scroller === "DROPDOWN")
546     {
547         vCalHeader +=
"<td align='center'><select name='MonthSelector' onChange='javascript:Cal.SwitchMth(this.selectedIndex);RenderCssCal();'>";
548         
for (i = 0; i < 12; i += 1)
549         {
550             
if (i === Cal.Month)
551             {
552                 SelectStr =
"Selected";
553             }
554             
else
555             {
556                 SelectStr =
"";
557             }
558             vCalHeader +=
"<option " + SelectStr + " value=" + i + ">" + MonthName[i] + "</option>";
559         }
560
561         vCalHeader +=
"</select></td>";
562         //Year selector
563
564         vCalHeader +=
"<td align='center'><select name='YearSelector' size='1' onChange='javascript:Cal.SwitchYear(this.value);RenderCssCal();'>";
565         
for (i = StartYear; i <= (dtToday.getFullYear() + EndYear); i += 1)
566         {
567             
if (i === Cal.Year)
568             {
569                 SelectStr =
'selected="selected"';
570             }
571             
else
572             {
573                 SelectStr =
'';
574             }
575             vCalHeader +=
"<option " + SelectStr + " value=" + i + ">" + i + "</option>\n";
576         }
577         vCalHeader +=
"</select></td>\n";
578         calHeight +=
30;
579     }
580
581     //******************End Month and Year selector
in dropdown list*********************
582
583     //******************Month and Year selector
in arrow*********************************
584
585     
else if (Cal.Scroller === "ARROW")
586     {
587         
if (UseImageFiles)
588         {
589             vCalHeader +=
"<td><img onmousedown='javascript:Cal.DecYear();RenderCssCal();' src='"+imageFilesPath+"cal_fastreverse.gif' width='13px' height='9' onmouseover='changeBorder(this, 0)' onmouseout='changeBorder(this, 1)' style='border:1px solid white'></td>\n";//Year scroller (decrease 1 year)
590             vCalHeader +=
"<td><img onmousedown='javascript:Cal.DecMonth();RenderCssCal();' src='" + imageFilesPath + "cal_reverse.gif' width='13px' height='9' onmouseover='changeBorder(this, 0)' onmouseout='changeBorder(this, 1)' style='border:1px solid white'></td>\n"; //Month scroller (decrease 1 month)
591             vCalHeader +=
"<td width='70%' class='calR' style='color:"+YrSelColor+"'>"+ Cal.GetMonthName(ShowLongMonth) + " " + Cal.Year + "</td>"; //Month and Year
592             vCalHeader +=
"<td><img onmousedown='javascript:Cal.IncMonth();RenderCssCal();' src='" + imageFilesPath + "cal_forward.gif' width='13px' height='9' onmouseover='changeBorder(this, 0)' onmouseout='changeBorder(this, 1)' style='border:1px solid white'></td>\n"; //Month scroller (increase 1 month)
593             vCalHeader +=
"<td><img onmousedown='javascript:Cal.IncYear();RenderCssCal();' src='" + imageFilesPath + "cal_fastforward.gif' width='13px' height='9' onmouseover='changeBorder(this, 0)' onmouseout='changeBorder(this, 1)' style='border:1px solid white'></td>\n"; //Year scroller (increase 1 year)
594             calHeight +=
22;
595         }
596         
else
597         {
598             vCalHeader +=
"<td><span id='dec_year' title='reverse year' onmousedown='javascript:Cal.DecYear();RenderCssCal();' onmouseover='changeBorder(this, 0)' onmouseout='changeBorder(this, 1)' style='border:1px solid white; color:" + YrSelColor + "'>-</span></td>";//Year scroller (decrease 1 year)
599             vCalHeader +=
"<td><span id='dec_month' title='reverse month' onmousedown='javascript:Cal.DecMonth();RenderCssCal();' onmouseover='changeBorder(this, 0)' onmouseout='changeBorder(this, 1)' style='border:1px solid white'>&lt;</span></td>\n";//Month scroller (decrease 1 month)
600             vCalHeader +=
"<td width='70%' class='calR' style='color:" + YrSelColor + "'>" + Cal.GetMonthName(ShowLongMonth) + " " + Cal.Year + "</td>\n"; //Month and Year
601             vCalHeader +=
"<td><span id='inc_month' title='forward month' onmousedown='javascript:Cal.IncMonth();RenderCssCal();' onmouseover='changeBorder(this, 0)' onmouseout='changeBorder(this, 1)' style='border:1px solid white'>&gt;</span></td>\n";//Month scroller (increase 1 month)
602             vCalHeader +=
"<td><span id='inc_year' title='forward year' onmousedown='javascript:Cal.IncYear();RenderCssCal();' onmouseover='changeBorder(this, 0)' onmouseout='changeBorder(this, 1)' style='border:1px solid white; color:" + YrSelColor + "'>+</span></td>\n";//Year scroller (increase 1 year)
603             calHeight +=
22;
604         }
605     }
606
607     vCalHeader +=
"</tr></table></td></tr>";
608
609     //******************End Month and Year selector
in arrow******************************
610
611     //Calendar header shows Month and Year
612     
if (ShowMonthYear && Cal.Scroller === "DROPDOWN")
613     {
614         vCalHeader +=
"<tr><td colspan='7' class='calR' style='color:" + MonthYearColor + "'>" + Cal.GetMonthName(ShowLongMonth) + " " + Cal.Year + "</td></tr>";
615         calHeight +=
19;
616     }
617
618     //Week day header
619
620     vCalHeader +=
"<tr><td colspan=\"7\"><table style='border-spacing:1px;border-collapse:separate;'><tr>";
621     
if (MondayFirstDay === true)
622     {
623         WeekDayName = WeekDayName2;
624     }
625     
else
626     {
627         WeekDayName = WeekDayName1;
628     }
629     
for (i = 0; i < 7; i += 1)
630     {
631         vCalHeader +=
"<td style='background-color:"+WeekHeadColor+";width:"+CellWidth+"px;color:#FFFFFF' class='calTD'>" + WeekDayName[i].substr(0, WeekChar) + "</td>";
632     }
633
634     calHeight +=
19;
635     vCalHeader +=
"</tr>";
636     //Calendar detail
637     CalDate =
new Date(Cal.Year, Cal.Month);
638     CalDate.setDate(
1);
639
640     vFirstDay = CalDate.getDay();
641
642     //Added version
1.7
643     
if (MondayFirstDay === true)
644     {
645         vFirstDay -=
1;
646         
if (vFirstDay === -1)
647         {
648             vFirstDay =
6;
649         }
650     }
651
652     //Added version
1.7
653     vCalData =
"<tr>";
654     calHeight +=
19;
655     
for (i = 0; i < vFirstDay; i += 1)
656     {
657         vCalData = vCalData + GenCell();
658         vDayCount = vDayCount +
1;
659     }
660
661     //Added version
1.7
662     
for (j = 1; j <= Cal.GetMonDays(); j += 1)
663     {
664         
if ((vDayCount % 7 === 0) && (j > 1))
665         {
666             vCalData = vCalData +
"<tr>";
667         }
668
669         vDayCount = vDayCount +
1;
670         //added version
2.1.2
671         
if (Cal.EnableDateMode === "future" && ((j < dtToday.getDate()) && (Cal.Month === dtToday.getMonth()) && (Cal.Year === dtToday.getFullYear()) || (Cal.Month < dtToday.getMonth()) && (Cal.Year === dtToday.getFullYear()) || (Cal.Year < dtToday.getFullYear())))
672         {
673             strCell = GenCell(j,
false, DisableColor, false); //Before today's date is not clickable
674         }
675         
else if (Cal.EnableDateMode === "past" && ((j >= dtToday.getDate()) && (Cal.Month === dtToday.getMonth()) && (Cal.Year === dtToday.getFullYear()) || (Cal.Month > dtToday.getMonth()) && (Cal.Year === dtToday.getFullYear()) || (Cal.Year > dtToday.getFullYear()))) {
676             strCell = GenCell(j,
false, DisableColor, false); //After today's date is not clickable
677         }
678         //
if End Year + Current Year = Cal.Year. Disable.
679         
else if (Cal.Year > (dtToday.getFullYear()+EndYear))
680         {
681             strCell = GenCell(j,
false, DisableColor, false);
682         }
683         
else if ((j === dtToday.getDate()) && (Cal.Month === dtToday.getMonth()) && (Cal.Year === dtToday.getFullYear()))
684         {
685             strCell = GenCell(j,
true, TodayColor);//Highlight today's date
686         }
687         
else
688         {
689             
if ((j === selDate.getDate()) && (Cal.Month === selDate.getMonth()) && (Cal.Year === selDate.getFullYear())){
690                  //modified version
1.7
691                 strCell = GenCell(j,
true, SelDateColor);
692             }
693             
else
694             {
695                 
if (MondayFirstDay === true)
696                 {
697                     
if (vDayCount % 7 === 0)
698                     {
699                         strCell = GenCell(j,
false, SundayColor);
700                     }
701                     
else if ((vDayCount + 1) % 7 === 0)
702                     {
703                         strCell = GenCell(j,
false, SaturdayColor);
704                     }
705                     
else
706                     {
707                         strCell = GenCell(j,
null, WeekDayColor);
708                     }
709                 }
710                 
else
711                 {
712                     
if (vDayCount % 7 === 0)
713                     {
714                         strCell = GenCell(j,
false, SaturdayColor);
715                     }
716                     
else if ((vDayCount + 6) % 7 === 0)
717                     {
718                         strCell = GenCell(j,
false, SundayColor);
719                     }
720                     
else
721                     {
722                         strCell = GenCell(j,
null, WeekDayColor);
723                     }
724                 }
725             }
726         }
727
728         vCalData = vCalData + strCell;
729
730         
if ((vDayCount % 7 === 0) && (j < Cal.GetMonDays()))
731         {
732             vCalData = vCalData +
"</tr>";
733             calHeight +=
19;
734         }
735     }
736
737     // finish the table proper
738
739     
if (vDayCount % 7 !== 0)
740     {
741         
while (vDayCount % 7 !== 0)
742         {
743             vCalData = vCalData + GenCell();
744             vDayCount = vDayCount +
1;
745         }
746     }
747
748     vCalData = vCalData +
"</table></td></tr>";
749
750
751     //Time picker
752     
if (Cal.ShowTime === true)
753     {
754         showHour = Cal.getShowHour();
755
756         
if (Cal.ShowSeconds === false && TimeMode === 24)
757         {
758             ShowArrows =
true;
759             HourCellWidth =
"10px";
760         }
761
762         vCalTime =
"<tr><td colspan='7' style=\"text-align:center;\"><table border='0' width='199px' cellpadding='0' cellspacing='0'><tbody><tr><td height='5px' width='" + HourCellWidth + "'>&nbsp;</td>";
763
764         
if (ShowArrows && UseImageFiles) //this is where the up and down arrow control the hour.
765         {
766             vCalTime +=
"<td style='vertical-align:middle;'><table cellspacing='0' cellpadding='0' style='line-height:0pt;width:100%;'><tr><td style='text-align:center;'><img onclick='nextStep(\"Hour\", \"plus\");' onmousedown='startSpin(\"Hour\", \"plus\");' onmouseup='stopSpin();' src='" + imageFilesPath + "cal_plus.gif' width='13px' height='9px' onmouseover='changeBorder(this, 0)' onmouseout='changeBorder(this, 1)' style='border:1px solid white'></td></tr><tr><td style='text-align:center;'><img onclick='nextStep(\"Hour\", \"minus\");' onmousedown='startSpin(\"Hour\", \"minus\");' onmouseup='stopSpin();' src='" + imageFilesPath + "cal_minus.gif' width='13px' height='9px' onmouseover='changeBorder(this, 0)' onmouseout='changeBorder(this, 1)' style='border:1px solid white'></td></tr></table></td>\n";
767         }
768
769         vCalTime +=
"<td width='22px'><input type='text' name='hour' maxlength=2 size=1 style=\"WIDTH:22px\" value=" + showHour + " onkeyup=\"javascript:Cal.SetHour(this.value)\">";
770         vCalTime +=
"</td><td style='font-weight:bold;text-align:center;'>:</td><td width='22px'>";
771         vCalTime +=
"<input type='text' name='minute' maxlength=2 size=1 style=\"WIDTH: 22px\" value=" + Cal.Minutes + " onkeyup=\"javascript:Cal.SetMinute(this.value)\">";
772
773         
if (Cal.ShowSeconds)
774         {
775             vCalTime +=
"</td><td style='font-weight:bold;'>:</td><td width='22px'>";
776             vCalTime +=
"<input type='text' name='second' maxlength=2 size=1 style=\"WIDTH: 22px\" value=" + Cal.Seconds + " onkeyup=\"javascript:Cal.SetSecond(parseInt(this.value,10))\">";
777         }
778
779         
if (TimeMode === 12)
780         {
781             SelectAm = (Cal.AMorPM ===
"AM") ? "Selected" : "";
782             SelectPm = (Cal.AMorPM ===
"PM") ? "Selected" : "";
783
784             vCalTime +=
"</td><td>";
785             vCalTime +=
"<select name=\"ampm\" onChange=\"javascript:Cal.SetAmPm(this.options[this.selectedIndex].value);\">\n";
786             vCalTime +=
"<option " + SelectAm + " value=\"AM\">AM</option>";
787             vCalTime +=
"<option " + SelectPm + " value=\"PM\">PM<option>";
788             vCalTime +=
"</select>";
789         }
790
791         
if (ShowArrows && UseImageFiles) //this is where the up and down arrow to change the "Minute".
792         {
793             vCalTime +=
"</td>\n<td style='vertical-align:middle;'><table cellspacing='0' cellpadding='0' style='line-height:0pt;width:100%'><tr><td style='text-align:center;'><img onclick='nextStep(\"Minute\", \"plus\");' onmousedown='startSpin(\"Minute\", \"plus\");' onmouseup='stopSpin();' src='" + imageFilesPath + "cal_plus.gif' width='13px' height='9px' onmouseover='changeBorder(this, 0)' onmouseout='changeBorder(this, 1)' style='border:1px solid white'></td></tr><tr><td style='text-align:center;'><img onmousedown='startSpin(\"Minute\", \"minus\");' onmouseup='stopSpin();' onclick='nextStep(\"Minute\",\"minus\");' src='" + imageFilesPath + "cal_minus.gif' width='13px' height='9px' onmouseover='changeBorder(this, 0)' onmouseout='changeBorder(this, 1)' style='border:1px solid white'></td></tr></table>";
794         }
795
796         vCalTime +=
"</td>\n<td align='right' valign='bottom' width='" + HourCellWidth + "px'></td></tr>";
797         vCalTime +=
"<tr><td colspan='8' style=\"text-align:center;\"><input style='width:60px;font-size:12px;' onClick='javascript:closewin(\"" + Cal.Ctrl + "\");' type=\"button\" value=\"OK\">&nbsp;<input style='width:60px;font-size:12px;' onClick='javascript: winCal.style.visibility = \"hidden\"' type=\"button\" value=\"Cancel\"></td></tr>";
798     }
799     
else //if not to show time.
800     {
801         vCalTime +=
"\n<tr>\n<td colspan='7' style=\"text-align:right;\">";
802         //close button
803         
if (UseImageFiles) {
804             vCalClosing +=
"<img onmousedown='javascript:closewin(\"" + Cal.Ctrl + "\"); stopSpin();' src='"+imageFilesPath+"cal_close.gif' width='16px' height='14px' onmouseover='changeBorder(this,0)' onmouseout='changeBorder(this, 1)' style='border:1px solid white'></td>";
805         }
806         
else {
807             vCalClosing +=
"<span id='close_cal' title='close'onmousedown='javascript:closewin(\"" + Cal.Ctrl + "\");stopSpin();' onmouseover='changeBorder(this, 0)'onmouseout='changeBorder(this, 1)' style='border:1px solid white; font-family: Arial;font-size: 10pt;'>x</span></td>";
808         }
809         vCalClosing +=
"</tr>";
810     }
811     vCalClosing +=
"</tbody></table></td></tr>";
812     calHeight +=
31;
813     vCalClosing +=
"</tbody></table>\n</span>";
814
815     //end time picker
816     funcCalback =
"function callback(id, datum) {";
817     funcCalback +=
" var CalId = document.getElementById(id);if (datum=== 'undefined') { var d = new Date(); datum = d.getDate() + '/' +(d.getMonth()+1) + '/' + d.getFullYear(); } window.calDatum=datum;CalId.value=datum;";
818     funcCalback +=
" if(Cal.ShowTime){";
819     funcCalback +=
" CalId.value+=' '+Cal.getShowHour()+':'+Cal.Minutes;";
820     funcCalback +=
" if (Cal.ShowSeconds) CalId.value+=':'+Cal.Seconds;";
821     funcCalback +=
" if (TimeMode === 12) CalId.value+=''+Cal.getShowAMorPM();";
822     funcCalback +=
"}if(CalId.onchange!=undefined) CalId.onchange();CalId.focus();winCal.style.visibility='hidden';}";
823
824
825     // determines
if there is enough space to open the cal above the position where it is called
826     
if (ypos > calHeight)
827     {
828         ypos = ypos - calHeight;
829     }
830
831     
if (!winCal)
832     {
833         headID = document.getElementsByTagName(
"head")[0];
834
835         //
add javascript function to the span cal
836         e = document.createElement(
"script");
837         e.type =
"text/javascript";
838         e.language =
"javascript";
839         e.text = funcCalback;
840         headID.appendChild(e);
841         //
add stylesheet to the span cal
842
843         cssStr =
".calTD {font-family: verdana; font-size: 12px; text-align: center; border:0; }\n";
844         cssStr +=
".calR {font-family: verdana; font-size: 12px; text-align: center; font-weight: bold;}";
845
846         style = document.createElement(
"style");
847         style.type =
"text/css";
848         style.rel =
"stylesheet";
849         
if (style.styleSheet)
850         { // IE
851             style.styleSheet.cssText = cssStr;
852         }
853
854         
else
855         { // w3c
856             cssText = document.createTextNode(cssStr);
857             style.appendChild(cssText);
858         }
859
860         headID.appendChild(style);
861         // create the outer frame that allows the cal. to be moved
862         span = document.createElement(
"span");
863         span.id = calSpanID;
864         span.style.position =
"absolute";
865         span.style.left = (xpos + CalPosOffsetX) +
'px';
866         span.style.top = (ypos - CalPosOffsetY) +
'px';
867         span.style.width = CalWidth +
'px';
868         span.style.border =
"solid 1pt " + SpanBorderColor;
869         span.style.padding =
"0";
870         span.style.cursor =
"move";
871         span.style.backgroundColor = SpanBgColor;
872         span.style.zIndex =
100;
873         document.body.appendChild(span);
874         winCal = document.getElementById(calSpanID);
875     }
876
877     
else
878     {
879         winCal.style.visibility =
"visible";
880         winCal.style.Height = calHeight;
881
882         //
set the position for a new calendar only
883         
if (bNewCal === true)
884         {
885             winCal.style.left = (xpos + CalPosOffsetX) +
'px';
886             winCal.style.top = (ypos - CalPosOffsetY) +
'px';
887         }
888     }
889
890     winCal.innerHTML = winCalData + vCalHeader + vCalData + vCalTime + vCalClosing;
891     
return true;
892 }
893
894
895 function NewCssCal(pCtrl, pFormat, pScroller, pShowTime, pTimeMode, pShowSeconds, pEnableDateMode)
896 {
897     //
get current date and time
898
899     dtToday =
new Date();
900     Cal =
new Calendar(dtToday);
901
902     
if (pShowTime !== undefined)
903     {
904         
if (pShowTime) {
905             Cal.ShowTime =
true;
906         }
907         
else {
908             Cal.ShowTime =
false;
909         }
910
911         
if (pTimeMode)
912         {
913             pTimeMode = parseInt(pTimeMode,
10);
914         }
915         
if (pTimeMode === 12 || pTimeMode === 24)
916         {
917             TimeMode = pTimeMode;
918         }
919         
else
920         {
921             TimeMode =
24;
922         }
923
924         
if (pShowSeconds !== undefined)
925         {
926             
if (pShowSeconds)
927             {
928                 Cal.ShowSeconds =
true;
929             }
930             
else
931             {
932                 Cal.ShowSeconds =
false;
933             }
934         }
935         
else
936         {
937             Cal.ShowSeconds =
false;
938         }
939
940     }
941
942     
if (pCtrl !== undefined)
943     {
944         Cal.Ctrl = pCtrl;
945     }
946
947     
if (pFormat!== undefined && pFormat !=="")
948     {
949         Cal.Format = pFormat.toUpperCase();
950     }
951     
else
952     {
953         Cal.Format =
"MMDDYYYY";
954     }
955
956     
if (pScroller!== undefined && pScroller!=="")
957     {
958         
if (pScroller.toUpperCase() === "ARROW")
959         {
960             Cal.Scroller =
"ARROW";
961         }
962         
else
963         {
964             Cal.Scroller =
"DROPDOWN";
965         }
966     }
967
968     
if (pEnableDateMode !== undefined && (pEnableDateMode === "future" || pEnableDateMode === "past")) {
969         Cal.EnableDateMode= pEnableDateMode;
970     }
971
972     exDateTime = document.getElementById(pCtrl).
value; //Existing Date Time value in textbox.
973
974     
if (exDateTime)
975     { //Parse existing Date String
976         
var Sp1 = exDateTime.indexOf(DateSeparator, 0),//Index of Date Separator 1
977         Sp2 = exDateTime.indexOf(DateSeparator, parseInt(Sp1,
10) + 1),//Index of Date Separator 2
978         tSp1,//Index of Time Separator
1
979         tSp2,//Index of Time Separator
2
980         strMonth,
981         strDate,
982         strYear,
983         intMonth,
984         YearPattern,
985         strHour,
986         strMinute,
987         strSecond,
988         winHeight,
989         offset = parseInt(Cal.Format.toUpperCase().lastIndexOf(
"M"), 10) - parseInt(Cal.Format.toUpperCase().indexOf("M"), 10) - 1,
990         strAMPM =
"";
991         //parse month
992
993         
if (Cal.Format.toUpperCase() === "DDMMYYYY" || Cal.Format.toUpperCase() === "DDMMMYYYY")
994         {
995             
if (DateSeparator === "")
996             {
997                 strMonth = exDateTime.substring(
2, 4 + offset);
998                 strDate = exDateTime.substring(
0, 2);
999                 strYear = exDateTime.substring(
4 + offset, 8 + offset);
1000             }
1001             
else
1002             {
1003                 
if (exDateTime.indexOf("D*") !== -1)
1004                 { //DTG
1005                     strMonth = exDateTime.substring(
8, 11);
1006                     strDate = exDateTime.substring(
0, 2);
1007                     strYear =
"20" + exDateTime.substring(11, 13); //Hack, nur für Jahreszahlen ab 2000
1008                 }
1009                 
else
1010                 {
1011                     strMonth = exDateTime.substring(Sp1 +
1, Sp2);
1012                     strDate = exDateTime.substring(
0, Sp1);
1013                     strYear = exDateTime.substring(Sp2 +
1, Sp2 + 5);
1014                 }
1015             }
1016         }
1017
1018         
else if (Cal.Format.toUpperCase() === "MMDDYYYY" || Cal.Format.toUpperCase() === "MMMDDYYYY"){
1019             
if (DateSeparator === ""){
1020                 strMonth = exDateTime.substring(
0, 2 + offset);
1021                 strDate = exDateTime.substring(
2 + offset, 4 + offset);
1022                 strYear = exDateTime.substring(
4 + offset, 8 + offset);
1023             }
1024             
else{
1025                 strMonth = exDateTime.substring(
0, Sp1);
1026                 strDate = exDateTime.substring(Sp1 +
1, Sp2);
1027                 strYear = exDateTime.substring(Sp2 +
1, Sp2 + 5);
1028             }
1029         }
1030
1031         
else if (Cal.Format.toUpperCase() === "YYYYMMDD" || Cal.Format.toUpperCase() === "YYYYMMMDD")
1032         {
1033             
if (DateSeparator === ""){
1034                 strMonth = exDateTime.substring(
4, 6 + offset);
1035                 strDate = exDateTime.substring(
6 + offset, 8 + offset);
1036                 strYear = exDateTime.substring(
0, 4);
1037             }
1038             
else{
1039                 strMonth = exDateTime.substring(Sp1 +
1, Sp2);
1040                 strDate = exDateTime.substring(Sp2 +
1, Sp2 + 3);
1041                 strYear = exDateTime.substring(
0, Sp1);
1042             }
1043         }
1044
1045         
else if (Cal.Format.toUpperCase() === "YYMMDD" || Cal.Format.toUpperCase() === "YYMMMDD")
1046         {
1047             
if (DateSeparator === "")
1048             {
1049                 strMonth = exDateTime.substring(
2, 4 + offset);
1050                 strDate = exDateTime.substring(
4 + offset, 6 + offset);
1051                 strYear = exDateTime.substring(
0, 2);
1052             }
1053             
else
1054             {
1055                 strMonth = exDateTime.substring(Sp1 +
1, Sp2);
1056                 strDate = exDateTime.substring(Sp2 +
1, Sp2 + 3);
1057                 strYear = exDateTime.substring(
0, Sp1);
1058             }
1059         }
1060
1061         
if (isNaN(strMonth)){
1062             intMonth = Cal.GetMonthIndex(strMonth);
1063         }
1064         
else{
1065             intMonth = parseInt(strMonth,
10) - 1;
1066         }
1067         
if ((parseInt(intMonth, 10) >= 0) && (parseInt(intMonth, 10) < 12)) {
1068             Cal.Month = intMonth;
1069         }
1070         //end parse month
1071
1072         //parse year
1073         YearPattern = /^\d{
4}$/;
1074         
if (YearPattern.test(strYear)) {
1075             
if ((parseInt(strYear, 10)>=StartYear) && (parseInt(strYear, 10)<= (dtToday.getFullYear()+EndYear)))
1076                 Cal.Year = parseInt(strYear,
10);
1077         }
1078         //end parse year
1079         
1080         //parse Date
1081         
if ((parseInt(strDate, 10) <= Cal.GetMonDays()) && (parseInt(strDate, 10) >= 1)) {
1082             Cal.Date = strDate;
1083         }
1084         //end parse Date
1085
1086         //parse time
1087
1088         
if (Cal.ShowTime === true)
1089         {
1090             //parse AM or PM
1091             
if (TimeMode === 12)
1092             {
1093                 strAMPM = exDateTime.substring(exDateTime.length -
2, exDateTime.length);
1094                 Cal.AMorPM = strAMPM;
1095             }
1096
1097             tSp1 = exDateTime.indexOf(
":", 0);
1098             tSp2 = exDateTime.indexOf(
":", (parseInt(tSp1, 10) + 1));
1099             
if (tSp1 > 0)
1100             {
1101                 strHour = exDateTime.substring(tSp1, tSp1 -
2);
1102                 Cal.SetHour(strHour);
1103
1104                 strMinute = exDateTime.substring(tSp1 +
1, tSp1 + 3);
1105                 Cal.SetMinute(strMinute);
1106
1107                 strSecond = exDateTime.substring(tSp2 +
1, tSp2 + 3);
1108                 Cal.SetSecond(strSecond);
1109
1110             }
1111             
else if (exDateTime.indexOf("D*") !== -1)
1112             { //DTG
1113                 strHour = exDateTime.substring(
2, 4);
1114                 Cal.SetHour(strHour);
1115                 strMinute = exDateTime.substring(
4, 6);
1116                 Cal.SetMinute(strMinute);
1117
1118             }
1119         }
1120
1121     }
1122     selDate =
new Date(Cal.Year, Cal.Month, Cal.Date);//version 1.7
1123     RenderCssCal(
true);
1124 }
1125
1126 function closewin(id) {
1127     
if (Cal.ShowTime === true) {
1128         
var MaxYear = dtToday.getFullYear() + EndYear;
1129         
var beforeToday =
1130                     (Cal.Date < dtToday.getDate()) &&
1131                     (Cal.Month === dtToday.getMonth()) &&
1132                     (Cal.Year === dtToday.getFullYear())
1133                     ||
1134                     (Cal.Month < dtToday.getMonth()) &&
1135                     (Cal.Year === dtToday.getFullYear())
1136                     ||
1137                     (Cal.Year < dtToday.getFullYear());
1138
1139         
if ((Cal.Year <= MaxYear) && (Cal.Year >= StartYear) && (Cal.Month === selDate.getMonth()) && (Cal.Year === selDate.getFullYear())) {
1140             
if (Cal.EnableDateMode === "future") {
1141                 
if (beforeToday === false) {
1142                     callback(id, Cal.FormatDate(Cal.Date));
1143                 }
1144             }
1145             
else
1146                 callback(id, Cal.FormatDate(Cal.Date));
1147         }
1148     }
1149     
1150     
var CalId = document.getElementById(id);
1151     CalId.focus();
1152     winCal.style.visibility =
'hidden';
1153 }
1154
1155 function changeBorder(element, col, oldBgColor)
1156 {
1157     
if (col === 0)
1158     {
1159         element.style.background = HoverColor;
1160         element.style.borderColor =
"black";
1161         element.style.cursor =
"pointer";
1162     }
1163
1164     
else
1165     {
1166         
if (oldBgColor)
1167         {
1168             element.style.background = oldBgColor;
1169         }
1170         
else
1171         {
1172             element.style.background =
"white";
1173         }
1174         element.style.borderColor =
"white";
1175         element.style.cursor =
"auto";
1176     }
1177 }
1178
1179 function selectDate(element, date) {
1180     Cal.Date = date;
1181     selDate =
new Date(Cal.Year, Cal.Month, Cal.Date);
1182     element.style.background = SelDateColor;
1183     RenderCssCal();
1184 }
1185
1186 function pickIt(evt)
1187 {
1188     
var objectID,
1189     dom,
1190     de,
1191     b;
1192     // accesses the element that generates the
event and retrieves its ID
1193     
if (document.addEventListener)
1194     { // w3c
1195         objectID = evt.target.id;
1196         
if (objectID.indexOf(calSpanID) !== -1)
1197         {
1198             dom = document.getElementById(objectID);
1199             cnLeft = evt.pageX;
1200             cnTop = evt.pageY;
1201
1202             
if (dom.offsetLeft)
1203             {
1204                 cnLeft = (cnLeft - dom.offsetLeft);
1205                 cnTop = (cnTop - dom.offsetTop);
1206             }
1207         }
1208
1209         //
get mouse position on click
1210         xpos = (evt.pageX);
1211         ypos = (evt.pageY);
1212     }
1213
1214     
else
1215     { // IE
1216         objectID =
event.srcElement.id;
1217         cnLeft =
event.offsetX;
1218         cnTop = (
event.offsetY);
1219
1220         //
get mouse position on click
1221         de = document.documentElement;
1222         b = document.body;
1223
1224         xpos =
event.clientX + (de.scrollLeft || b.scrollLeft) - (de.clientLeft || 0);
1225         ypos =
event.clientY + (de.scrollTop || b.scrollTop) - (de.clientTop || 0);
1226     }
1227
1228     // verify
if this is a valid element to pick
1229     
if (objectID.indexOf(calSpanID) !== -1)
1230     {
1231         domStyle = document.getElementById(objectID).style;
1232     }
1233
1234     
if (domStyle)
1235     {
1236         domStyle.zIndex =
100;
1237         
return false;
1238     }
1239
1240     
else
1241     {
1242         domStyle =
null;
1243         
return;
1244     }
1245 }
1246
1247
1248
1249 function dragIt(evt)
1250 {
1251     
if (domStyle)
1252     {
1253         
if (document.addEventListener)
1254         { //
for IE
1255             domStyle.left = (
event.clientX - cnLeft + document.body.scrollLeft) + 'px';
1256             domStyle.top = (
event.clientY - cnTop + document.body.scrollTop) + 'px';
1257         }
1258         
else
1259         { //Firefox
1260             domStyle.left = (evt.clientX - cnLeft + document.body.scrollLeft) +
'px';
1261             domStyle.top = (evt.clientY - cnTop + document.body.scrollTop) +
'px';
1262         }
1263     }
1264 }
1265
1266 // performs a single increment or decrement
1267 function nextStep(whatSpinner, direction)
1268 {
1269     
if (whatSpinner === "Hour")
1270     {
1271         
if (direction === "plus")
1272         {
1273             Cal.SetHour(Cal.Hours +
1);
1274             RenderCssCal();
1275         }
1276         
else if (direction === "minus")
1277         {
1278             Cal.SetHour(Cal.Hours -
1);
1279             RenderCssCal();
1280         }
1281     }
1282     
else if (whatSpinner === "Minute")
1283     {
1284         
if (direction === "plus")
1285         {
1286             Cal.SetMinute(parseInt(Cal.Minutes,
10) + 1);
1287             RenderCssCal();
1288         }
1289         
else if (direction === "minus")
1290         {
1291             Cal.SetMinute(parseInt(Cal.Minutes,
10) - 1);
1292             RenderCssCal();
1293         }
1294     }
1295
1296 }
1297
1298 // starts the time spinner
1299 function startSpin(whatSpinner, direction)
1300 {
1301     document.thisLoop = setInterval(function ()
1302     {
1303         nextStep(whatSpinner, direction);
1304     },
125); //125 ms
1305 }
1306
1307 //stops the time spinner
1308 function stopSpin()
1309 {
1310     clearInterval(document.thisLoop);
1311 }
1312
1313 function dropIt()
1314 {
1315     stopSpin();
1316
1317     
if (domStyle)
1318     {
1319         domStyle =
null;
1320     }
1321 }
1322
1323 // Default events configuration
1324
1325 document.onmousedown = pickIt;
1326 document.onmousemove = dragIt;
1327 document.onmouseup = dropIt;


Gõ tìm kiếm nhanh...